<template>
  <div class="commonBox">
    <div class="header" :style="{ background: state.bg }">
      <p>
        <slot name="title"></slot>
      </p>
    </div>
    <div class="tag" v-show="props.tagName">
      {{ props.tagName }}：<span>{{ props.tagValue }}{{ props.tagUnit }}</span>
    </div>
    <div class="content">
      <slot name="content"></slot>
    </div>
  </div>
</template>

<script setup lang="ts">
  import header_bg_small from '@/assets/imgs/billboard/header_bg_small.png'
  import header_bg_large from '@/assets/imgs/billboard/header_bg_large.png'
  const props = defineProps({
    type: {
      type: String,
      default: 'small'
    },
    tagName: {
      type: String,
      default: ''
    },
    tagValue: {
      type: Number,
      default: 0
    },
    tagUnit: {
      type: String,
      default: ''
    }
  })
  const state = reactive({
    bg: ''
  })
  watch(
    () => props.type,
    (newVal) => {
      if (newVal === 'small') {
        state.bg = `url(${header_bg_small}) no-repeat center 4px/100% 100%`
      } else {
        state.bg = `url(${header_bg_large}) no-repeat center 4px/100% 100%`
      }
    },
    { immediate: true }
  )
</script>

<style lang="scss" scoped>
  .commonBox {
    width: 100%;
    height: 100%;
    position: relative;
    .header {
      width: 100%;
      height: 40px;
      > p {
        background: linear-gradient(180deg, #fff, #71d7ff);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        color: transparent;
        font-size: 18px;
        font-weight: 600;
        padding-left: 40px;
        box-sizing: border-box;
      }
    }
    .tag {
      position: absolute;
      top: -4px;
      right: 0;
      padding: 0 10px;
      height: 40px;
      line-height: 40px;
      font-size: 12px;
      font-weight: 600;
      background: linear-gradient(180deg, #fff, #71d7ff);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      color: transparent;
      span {
        font-size: 16px;
        font-style: italic;
      }
    }
    .content {
      width: 100%;
      height: calc(100% - 40px);
    }
  }
</style>
